package com.zfei.gfb.api.domain;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 更新
 *
 * @author fgh
 */
public class Update implements Serializable {

    /**
     * ID
     */
    private String id;

    /**
     * 更新类型
     */
    private String type;

    /**
     * 更新用户
     */
    private String user;

    /**
     * 更新理由
     */
    private String reason;

    /**
     * 更新时间
     */
    private Long time;

    /**
     * 附件
     */
    private Map<String, String> attachments;

    public Update() {
    }

    public Update(String id) {
        this.id = id;
    }

    public Update(String id, String type) {
        this.id = id;
        this.type = type;
    }

    public Update(String id, String type, String user) {
        this.id = id;
        this.type = type;
        this.user = user;
    }

    public Update(String id, String type, String user, String reason) {
        this.id = id;
        this.type = type;
        this.user = user;
        this.reason = reason;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public Map<String, String> getAttachments() {
        return attachments;
    }

    public void setAttachments(Map<String, String> attachments) {
        this.attachments = attachments;
    }

    public String getAttachment(String key) {
        if (this.getAttachments() == null) {
            this.setAttachments(new LinkedHashMap<>());
        }

        return this.getAttachments().get(key);
    }

    public Update setAttachment(String key, String value) {
        if (this.getAttachments() == null) {
            this.setAttachments(new LinkedHashMap<>());
        }

        if (value == null) {
            this.getAttachments().remove(key);
        } else {
            this.getAttachments().put(key, value);
        }
        return this;
    }
}
